<?php

class CriteresRechercheActivite {

	var $actidsai;
	var $actlblib;
	var $actidniv;
	var $actidtra;
	var $actidpro;
	var $actlbjou;
	var $actlbhdb;
	var $actlbdfn;
	var $actidsit;
	
	// pagination
	var $offset;
	var $maxResult;
	
	/**
	 * Constructeur
	 */
	function CriteresRechercheActivite(){
		$this->offset = 0;
		$this->maxResult = 0;
	}
	
	function setCriterionsFromInput($inputObject) {
		$actidsai_rech = $inputObject->post('actidsai_rech');
		$actlblib_rech = $inputObject->post('actlblib_rech');
		$actidniv_rech = $inputObject->post('actidniv_rech');
		$actidtra_rech = $inputObject->post('actidtra_rech');
		$actidpro_rech = $inputObject->post('actidpro_rech');
		$actlbjou_rech = $inputObject->post('actlbjou_rech');
		$actlbhdb_rech = $inputObject->post('actlbhdb_rech');
		$actlbdfn_rech = $inputObject->post('actlbdfn_rech');
		$actidsit_rech = $inputObject->post('actidsit_rech');
		
		$this->actidsai = ( $actidsai_rech != "" )?($actidsai_rech):(null);
		$this->actlblib = ( $actlblib_rech != "" )?($actlblib_rech):(null);
		$this->actlblib = ( $actlblib_rech != "" )?($actlblib_rech):(null);
		$this->actidniv = ( $actidniv_rech != "" )?($actidniv_rech):(null);
		$this->actidtra = ( $actidtra_rech != "" )?($actidtra_rech):(null);
		$this->actidpro = ( $actidpro_rech != "" )?($actidpro_rech):(null);
		$this->actlbjou = ( $actlbjou_rech != "" )?($actlbjou_rech):(null);
		$this->actlbhdb = ( $actlbhdb_rech != "" )?($actlbhdb_rech):(null);
		$this->actlbdfn = ( $actlbdfn_rech != "" )?($actlbdfn_rech):(null);
		$this->actidsit = ( $actidsit_rech != "" )?($actidsit_rech):(null);
		
	}
	
	function search($db) {
		$rows = getAllactivitesFromDBHaving($db, $this->actidsai, $this->actlblib, $this->actidniv, 
			$this->actidtra, $this->actidpro, $this->actlbjou, $this->actlbhdb,
			$this->actlbdfn, $this->actidsit);
		$records = array();
		foreach ($rows as $row) {
			$records[$row['actidact']] = activite_model::activite_modelFromRow($row);
		}
		return $records;
	}
}

?>